<?php
/**
 * PISOneAM
 *
 * 专业IT监控系统
 *
 * @package		PISOneAM
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc.
 * @license		http://www.m135.com/license.html
 * @link		http://www.m135.com
 * @since		Version 1.0
 * @filesource
 */
class musers extends CI_Model
{
	
	const TBL_USERS = 'users';//表名
	
	public $_id;//用户表ID
	public $_UserAccount;//用户账户
	public $_UserName;//用户名
	public $_PassWord;//密码
	public $_DelFlag;//删除标志
	
	
	/**
	* 增加用户
	* @author PISOne项目开发团队  
	* @param 
	* @return int/bool/object/array
	*/
	public function add_user($userData)
	{
		
		//$userData['PassWord'] =Common::do_hash($userData['PassWord']);
		$this->db->insert(self::TBL_USERS,$userData);
		return ($this->db->affected_rows()>0)?True:False;
		
	}
	/**
	* 依据ID获取用户信息
	* @author PISOne项目开发团队  
	* @param 
	* @return int/bool/object/array
	*/
	public function get_userbyid ($id)
	{
		$data = array();
		$data = $this->db->select('*')->from(self::TBL_USERS)->where('Id',$id)->limit(1);
		$query = $this->db->get();
		if($query->num_rows()>0)
		{
			$data=$query->row_array();
		}
		$query->free_result();//释放数组
		return $data;
	}
	/**
	* 校验用户
	* @author PISOne项目开发团队  
	* @param 
	* @return int/bool/object/array
	*/
	public function validate_user($UserAccount, $PassWord)
	{
		$data = FALSE;
		$this->db->where('UserAccount',$UserAccount);
		$query=$this->db->get(self::TBL_USERS);
		if($query->num_rows()==1)
		{
			$data = $query->row_array();
		}
		if(!empty($data))//如果$data不是空
		{
			//$data=(Common::hash_Validate($PassWord, $data['PassWord']))?$data:False;
			$this->_UserName=$data['UserName'];
			$data = $data['PassWord']==$PassWord?$data:FALSE;
		}
		$query->free_result();
		return $data;
	}
	
	
	
	
}